package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmSensitivePageDto;
import com.heima.model.wemedia.pojos.WmSensitive;
import com.heima.wemedia.service.WmSensitiveService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * 敏感词管理
 */
@RestController
@Slf4j
@RequiredArgsConstructor
@RequestMapping("/api/v1/sensitive")
public class WmSensitiveController {

    //sensitive
    private final WmSensitiveService wmSensitiveService;

    /**
     * 分页查看敏感词
     *
     * @param wmSensitivePageDto
     * @return
     */
    @PostMapping("/list")
    public ResponseResult listSensitive(@RequestBody WmSensitivePageDto wmSensitivePageDto) {

        log.info("分页查看敏感词...{}", wmSensitivePageDto);

        return wmSensitiveService.listSensitive(wmSensitivePageDto);

    }


    /**
     * 新增敏感词
     *
     * @param wmSensitive
     * @return
     */
    @PostMapping("/save")
    public ResponseResult saveSensitive(@RequestBody WmSensitive wmSensitive) {

        log.info("新增敏感词...{}", wmSensitive);

        return wmSensitiveService.saveSensitive(wmSensitive);

    }

    /**
     * 修改敏感词
     *
     * @param wmSensitive
     * @return
     */
    @PostMapping("/update")
    public ResponseResult updateSensitive(@RequestBody WmSensitive wmSensitive) {

        log.info("修改敏感词...{}", wmSensitive);

        return wmSensitiveService.updeteSensitive(wmSensitive);

    }

    /**
     * 删除敏感词
     *
     * @param id
     * @return
     */
    @DeleteMapping("/del/{id}")
    public ResponseResult updateSensitive(@PathVariable Integer id) {

        log.info("删除敏感词...{}", id);

        return wmSensitiveService.deleteSensitive(id);

    }


}


















